package middleWare

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"log"
	"time"
)

func MiddleWare() gin.HandlerFunc {
	return func(c *gin.Context) {
		// 获取header信息
		authToken := c.Request.Header.Get("Authorization")
		fmt.Println("中间件获取的头部信息的token ", authToken)
		fmt.Println("这是中间件, 请求地址是...", c.Request.URL.Path)
	}
}


// FuncCostTime 统计函数的消费时间
func FuncCostTime() gin.HandlerFunc {
	return func(c *gin.Context) {
		log.Printf("进入统计时间中间件... 开始计时！")
		now := time.Now()
		c.Next()
		costTime := time.Since(now)
		log.Printf("方法消耗时间= %v", costTime)
	}
}

